//
//  RegisterCell.m
//  ChatForHot
//
//  Created by FLY on 2018/10/11.
//  Copyright © 2018年 FLY. All rights reserved.
//

#import "RegisterCell.h"

@implementation RegisterCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.selectedBackgroundView = [UIView new];
        self.clipsToBounds = YES;
        
        [self.contentView addSubview:self.HOTCHATbackView];
        [self.contentView addSubview:self.HOTCHATtitleLab];
        [self.contentView addSubview:self.HOTCHATcontentLab];
        [self.HOTCHATbackView addSubview:self.HOTCHATlineView];
        [self.contentView addSubview:self.HOTCHATarrowImgView];
        
        [self.HOTCHATbackView mas_updateConstraints:^(MASConstraintMaker *make) {
            
            make.top.bottom.equalTo(self.contentView);
            make.left.equalTo(self.contentView).offset(30);
            make.right.equalTo(self.contentView).offset(-30);
        }];
        [self.HOTCHATtitleLab mas_updateConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(self.HOTCHATbackView).offset(15);
            make.centerY.equalTo(self.contentView);
        }];
        [self.HOTCHATcontentLab mas_updateConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.HOTCHATarrowImgView.mas_left).offset(-10);
            make.centerY.equalTo(self.contentView);
        }];
        [self.HOTCHATarrowImgView mas_updateConstraints:^(MASConstraintMaker *make) {
            
            make.right.equalTo(self.HOTCHATbackView).offset(-12);
            make.centerY.equalTo(self.contentView);
        }];

        [self.HOTCHATlineView mas_updateConstraints:^(MASConstraintMaker *make) {
            
            make.right.bottom.equalTo(self);
            make.left.equalTo(self.HOTCHATtitleLab.mas_left);
            make.height.mas_equalTo(0.5);
        }];
        
    }
    return self;
}
- (void)setModel:(UserInfoModel *)model{
    
    _model = model;

    
    switch (self.indexPath.row) {
        case 0:{
            self.HOTCHATtitleLab.text = NSLocalizedString(@"StrN022", nil);
            if ([NSString stringWithFormat:@"%@",_model.age].length == 0 || !_model.age){
                self.HOTCHATcontentLab.text = @"";
            }else{
                self.HOTCHATcontentLab.text = [NSString stringWithFormat:@"%@",self.model.age];
            }
            
            [self.HOTCHATbackView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.contentView);
                make.bottom.equalTo(self.contentView).offset(10);
                make.left.equalTo(self.contentView).offset(30);
                make.right.equalTo(self.contentView).offset(-30);
            }];
        }
            break;
        case 1:{
            self.HOTCHATtitleLab.text = NSLocalizedString(@"StrN023", nil);
            NSString *heightStr = @"";
            if ([NSString stringWithFormat:@"%@",_model.minFeet].length == 0 || [NSString stringWithFormat:@"%@",_model.maxFeet].length == 0 || !_model.minFeet || !_model.maxFeet) {
                
                heightStr = @"";
            }else{
                heightStr = [NSString stringWithFormat:@"%@’%@”",_model.minFeet,_model.maxFeet];
            }
            self.HOTCHATcontentLab.text = heightStr;//self.model.height;
            [self.HOTCHATbackView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.contentView).offset(-10);
                make.bottom.equalTo(self.contentView).offset(10);
                make.left.equalTo(self.contentView).offset(30);
                make.right.equalTo(self.contentView).offset(-30);
            }];
        }
            break;
        case 2:{
            self.HOTCHATtitleLab.text = NSLocalizedString(@"StrN024", nil);
            if ([NSString stringWithFormat:@"%@",_model.weight].length == 0 || !_model.weight){
                self.HOTCHATcontentLab.text = @"";
            }else {
                self.HOTCHATcontentLab.text = [UserInfoModel HOTCHATgetTypeNameWith:[NSString stringWithFormat:@"%@",_model.weight]];
            }
            [self.HOTCHATbackView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.contentView).offset(-10);
                make.bottom.equalTo(self.contentView);
                make.left.equalTo(self.contentView).offset(30);
                make.right.equalTo(self.contentView).offset(-30);
            }];
        }
            break;
            
        default:
            break;
    }
}

//lazzy
- (UIView *)HOTCHATbackView{
    
    if (_HOTCHATbackView == nil) {
        
        _HOTCHATbackView = [[UIView alloc]init];
        _HOTCHATbackView.layer.masksToBounds = YES;
        _HOTCHATbackView.layer.cornerRadius = 4;
        _HOTCHATbackView.backgroundColor = [UIColor whiteColor];
    }
    return _HOTCHATbackView;
}
- (UILabel *)HOTCHATtitleLab{
    
    if (_HOTCHATtitleLab == nil) {
        
        _HOTCHATtitleLab = [[UILabel alloc]init];
        _HOTCHATtitleLab.textColor = HOTCHATHexColor(0xABA5B3);
        _HOTCHATtitleLab.font = [UIFont systemFontOfSize:15];
    }
    return _HOTCHATtitleLab;
}
- (UILabel *)HOTCHATcontentLab{
    
    if (_HOTCHATcontentLab == nil) {
        
        _HOTCHATcontentLab = [[UILabel alloc]init];
        _HOTCHATcontentLab.textColor = HOTCHATHexColor(0x111111);
        _HOTCHATcontentLab.font = [UIFont systemFontOfSize:15];
        _HOTCHATcontentLab.text = @"";
    }
    return _HOTCHATcontentLab;
}
- (UIView *)HOTCHATlineView{
    
    if (_HOTCHATlineView == nil) {
        
        _HOTCHATlineView = [[UILabel alloc]init];
        _HOTCHATlineView.backgroundColor = HOTCHATHexColor(0xE7E7E7);
    }
    return _HOTCHATlineView;
}
- (UIImageView *)HOTCHATarrowImgView{
    
    if (_HOTCHATarrowImgView == nil) {
        
        _HOTCHATarrowImgView = [[UIImageView alloc]init];
        _HOTCHATarrowImgView.image =  [UIImage imageNamed:@"all_more"];
    }
    return _HOTCHATarrowImgView;
}
@end
